package com.java.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.java.mis.UserType;
/**
 * 用户
 * @author wqf
 * @version  Nov 24, 2011 9:49:12 AM
 */
@Entity
@org.hibernate.annotations.Entity(
		selectBeforeUpdate = true, 
		dynamicInsert = true, 
		dynamicUpdate = true
)
@Table(name="user")
public class User implements Serializable {
	
	private static final long serialVersionUID = 4298448765715271022L;

	@Id
	@GeneratedValue
	private Long id;
	
	/**
	 * 用户名称
	 */
	@Column(length=20)
	private String userName;
	
	/**
	 * 账号
	 */
	@Column(length=20)
	private String account;
	
	/**
	 * 密码
	 */
	@Column(length=20)
	private String password;
		
	/**
	 * 业务员代号
	 */
	@Column(length=20)
	private String code;
	
	/**
	 * 性别
	 */
	@Column
	private Boolean sex;
	
	/**
	 * 联系电话
	 */
	@Column(length=30)
	private String telphone;
	
	/**
	 * Email
	 */
	@Column(length=30)
	private String email;
	
	/**
	 * 联系地址
	 */
	@Column(length=100)
	private String address;
	
	/**
	 * 所属部门
	 */
	@ManyToOne(optional=true)
	@JoinColumn(name="department_id",referencedColumnName="id")
	@NotFound(action=NotFoundAction.IGNORE)
	private Department department;
	
	/**
	 * 所属角色
	 */
//	@ManyToOne(optional=true)
//	@JoinColumn(name="role_id",referencedColumnName="id")
//	@NotFound(action=NotFoundAction.IGNORE)
//	private Role role;
	
	/**
	 * 创建日期
	 */
	@Temporal(TemporalType.TIMESTAMP)	
	private Date createdDate;
	
	/**
	 * 入职日期
	 */
	@Temporal(TemporalType.TIMESTAMP)	
	private Date entryDate;
	
	/**
	 * 最后登录时间
	 */
	@Temporal(TemporalType.TIMESTAMP)	
	private Date lastLoginTime;
	
	/**
	 * 状态
	 */
	@Column
	private Boolean status=true;
	
	/**
	 * 超级管理员
	 */
//	@Column
//	private Boolean isAdmin=false;
	
	/**
	 * 权限
	 * 0 超级管理员
	 * 1 录入员
	 * 2 业务员
	 */
	@Column
	@Enumerated(EnumType.STRING)
	private UserType userType=UserType.select;
	
	/**
	 * 部门管理员
	 */
	@Column
	private Boolean isDeptAdmin=false;
	
	/**
	 * 描述
	 */
	@Column(length=200)
	private String detail;
		

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Boolean getSex() {
		return sex;
	}

	public void setSex(Boolean sex) {
		this.sex = sex;
	}

	public Boolean getStatus() {
		return status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}

	public String getTelphone() {
		return telphone;
	}

	public void setTelphone(String telphone) {
		this.telphone = telphone;
	}
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getEntryDate() {
		return entryDate;
	}

	public void setEntryDate(Date entryDate) {
		this.entryDate = entryDate;
	}
	
	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}
	
	public Boolean getIsDeptAdmin() {
		return isDeptAdmin;
	}

	public void setIsDeptAdmin(Boolean isDeptAdmin) {
		this.isDeptAdmin = isDeptAdmin;
	}

	public UserType getUserType() {
		return userType;
	}

	public void setUserType(UserType userType) {
		this.userType = userType;
	}
}
